
package org.jetnuke.modules.blog;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.jforum.dao.ThemeDAO;

import org.apache.velocity.VelocityContext;
import org.jetnuke.common.ActionForward;
import org.jetnuke.common.IAction;
import org.jetnuke.common.IAdminInfo;
import org.jetnuke.common.IModuleInfo;
import org.jetnuke.common.IUserInfo;
import org.jetnuke.dao.BlogUserSettingsDAO;
import org.jetnuke.dao.DataAccessDriver;
import org.jetnuke.entities.BlogUserSettings;
import org.jetnuke.util.JetUtil;

public class UpdateUserTheme implements IAction {
	int theme;
	public ActionForward exec(HttpServletRequest request,
			HttpServletResponse response, VelocityContext vc, IModuleInfo info,
			String op, IUserInfo ui, IAdminInfo ai) throws Exception {
		if(ui==null || ui.getID()<2)
			return null;
		BlogUserSettingsDAO busm=DataAccessDriver.getInst().newBlogUserSettingsDAO();
		BlogUserSettings bus=busm.retrieveByPk(ui.getID());
		bus.setSTYLE(theme);
		busm.update(bus);
		JetUtil.redirect(vc,response,request.getContextPath()+"/do/blog/your_blog");
		return null;
	}
	public void setTheme(int theme) {
		ThemeDAO tm=net.jforum.dao.DataAccessDriver.getInstance().newThemeDAO();
		try {
			tm.selectByID(theme);
			this.theme = theme;
		} catch (Exception e) {
		}
		
	}
}
